<!-- 标题 -->
<template>
    <div class="title-ele" :style="boxStyle">
        <div class="title-text">
            <template v-if="mode === 0">
                <span :style="{
                    color: element.eles.style.color
                }">
                    <span>
                        {{ element.eles.content }}
                    </span>
                </span>
            </template>
            <template v-else-if="mode === 1">
                <div class="mark1 mark_warp_left">
                    <span class="mark1" :style="{
                        color: element.eles.customFeature.markColor,
                        backgroundColor: element.eles.customFeature.markColor,
                        right: element.eles.customFeature['markMargin-right']
                    }"></span>
                </div>
                <span :style="{
                    color: element.eles.style.color
                }">
                    {{ element.eles.content }}
                </span>
            </template>
            <template v-else-if="mode === 2">
                <span class="mark_bottom" :style="{
                    paddingBottom: element.eles.customFeature['markMargin-top']
                }">
                    <span>{{ element.eles.content }}</span>
                    <span class="mark2" :style="{
                        color: element.eles.customFeature.markColor,
                        backgroundColor: element.eles.customFeature.markColor,
                        bottom: 0
                    }"></span>
                </span>
            </template>
            <template v-else-if="mode === 3">
                <div class="mark3 mark_warp_left">
                    <span class="mark1 mark3" :style="{
                        color: element.eles.customFeature.markColor,
                        backgroundColor: element.eles.customFeature.markColor,
                        right: element.eles.customFeature['markMargin-right']
                    }"></span>
                </div>
                <span :style="{
                    color: element.eles.style.color
                }">
                    {{ element.eles.content }}
                </span>
            </template>
        </div>
    </div>
</template>

<script>
import { defineComponent, toRefs, computed } from 'vue'
export default defineComponent({
    name: 'WidgetTitleEle',
    props: {
        element: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props, { emit }) {
        const { element } = toRefs(props)

        const mode = computed(() => element.value.eles.customFeature.mode)

        const boxStyle = computed(() => {
            const style = element.value.eles.style || {}
            return {
                width: style.width,
                color: style.color,
                opacity: style.opacity,
                marginTop: style['margin-top'],
                marginLeft: style['margin-left'],
                marginRight: style['margin-right'],
                marginBottom: style['margin-bottom'],
                backgroundColor: style['background-color'],
                backgroundImage: style['background-image'],
                borderStyle: style['border-style'],
                borderColor: style['border-color'],
                borderWidth: style['border-width'],
                borderRadius: style['border-radius'],
                lineHeight: style['line-height'],
                fontSize: style['font-size'],
                fontStyle: style['font-style'],
                fontWeight: style['font-weight'],
                textAlign: style['text-align'],
                textDecoration: style['text-decoration'],
                boxShadow: style['box-shadow']
            }
        })
        
        return {
            element,
            mode,
            boxStyle
        }
    }
})
</script>

<style lang="less" scoped>
@import './widget-title-ele.less';
</style>